package com.atguigu.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

@SpringBootConfiguration
public class RabbitMQConfig {
    //配置队列
    @Bean("queue")
    public Queue queue(){
        return QueueBuilder.durable("boot_mq").build();
    }
    //配置交换机
    @Bean("exchange")
    public Exchange exchange(){
        return ExchangeBuilder.directExchange("boot_exchange").durable(true).build();
    }
    //绑定
    @Bean
    public Binding binding(@Qualifier("queue") Queue queue,@Qualifier("exchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("boot_key").noargs();

    }

}
